var a = require("../../../@babel/runtime/helpers/defineProperty"), t = getApp();

Page({
    data: {
        keyword: "",
        activeName: 0,
        dataList: [],
        titleArr: [],
        isLoadMore: !0
    },
    onLoad: function(a) {
        this.init();
    },
    init: function() {
        this.isLoadMore = !0, this.setData({
            titleArr: [ {
                id: 0,
                name: "全部"
            }, {
                id: 1,
                name: "未签署"
            }, {
                id: 2,
                name: "已签署"
            } ]
        }), this.setNewArr();
    },
    setNewArr: function() {
        var a = [];
        this.data.titleArr.forEach(function(t, e) {
            a.push({
                isLoadMore: !0,
                loading: !1,
                finished: !1,
                page: 1,
                total_page: 0,
                list: []
            });
        }), this.setData({
            dataList: a
        }), this.handleClick();
    },
    handleClick: function(e) {
        var i = this;
        e && this.setData({
            activeName: e.detail.name
        });
        var s = t.getNetAddresss("plugin.hand-sign-protocol.frontend.controllers.protocol.index");
        s = s + "&page=1&search[title]=" + this.data.keyword + "&search[status]=" + this.data.activeName, 
        t._getNetWork({
            url: s,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (i.setData(a({}, "dataList[" + i.data.activeName + "].list", e.data.list.data)), 
                i.data.isLoadMore = !0, i.data.dataList[i.data.activeName].isLoadMore = !0, i.data.dataList[i.data.activeName].page = 1, 
                i.data.dataList[i.data.activeName].total_page = e.data.list.last_page) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    onChangeKey: function(a) {
        this.setData({
            keyword: a.detail
        });
    },
    onSearch: function() {
        this.handleClick();
    },
    toUrl: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageI/handwrittenEsign/handwrittenEsignIndex/handwrittenEsignIndex?id=" + t
        });
    },
    _getMoreData: function() {
        var e = this;
        if (this.data.dataList[this.data.activeName].isLoadMore = !1, !(this.data.dataList[this.data.activeName].page >= this.data.dataList[this.data.activeName].total_page)) {
            this.data.dataList[this.data.activeName].page = this.data.dataList[this.data.activeName].page + 1;
            var i = t.getNetAddresss("plugin.hand-sign-protocol.frontend.controllers.protocol.index");
            i = i + "&page=" + this.data.dataList[this.data.activeName].page + "&search[title]=" + this.data.keyword + "&search[status]=" + this.data.activeName, 
            t._getNetWork({
                url: i,
                data: {},
                success: function(t) {
                    var i = t.data;
                    if (1 == i.result) {
                        var s, d = i.data.list.data;
                        e.setData((a(s = {}, "dataList[" + e.data.activeName + "].isLoadMore", !0), a(s, "dataList[" + e.data.activeName + "].list", e.data.dataList[e.data.activeName].list.concat(d)), 
                        s));
                    } else {
                        var o;
                        e.setData((a(o = {}, "dataList[" + e.data.activeName + "].isLoadMore", !1), a(o, "dataList[" + e.data.activeName + "].page", e.data.dataList[e.data.activeName].page - 1), 
                        o));
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.dataList[this.data.activeName].isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});